<?php
/**
 * Created by PhpStorm.
 * User: Giles
 * Date: 2017/7/27
 * Time: 15:29
 */
namespace Admin\Controller;


class OrderController extends BaseController
{
    /**
     * 列表
     *
     */
    public function index()
    {
        $this->display();
    }

    public function ajaxGetIndex() {
        $postData = I('post.');
        $start = $postData['start'] ? $postData['start'] : 0;
        $limit = $postData['length'] ? $postData['length'] : 20;
        $draw = $postData['draw'];
        $where = array();
        $getInfo = I('get.');
        if (isset($getInfo['userName']) && !empty($getInfo['userName'])) {
            $where['userName'] = urldecode($getInfo['userName']);
        }
        if (isset($getInfo['userPhone']) && !empty($getInfo['userPhone'])) {
            $where['userPhone'] = $getInfo['userPhone'];
        }
        $total = D('ApiOrders')->where($where)->count();
        $info = D('ApiOrders')->where($where)->limit($start, $limit)->select();
        //echo D('ApiOrders')->getLastSql();
        $data = array(
            'draw'            => $draw,
            'recordsTotal'    => $total,
            'recordsFiltered' => $total,
            'data'            => $info
        );
        $this->ajaxReturn($data, 'json');
    }
}